﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ServicioWebRest.Areas.Api.Models;

namespace ServicioWebRest.Areas.Api.Controllers
{
    public class TesoreriaController : Controller
    {

        private TesoreriaManager tesoreriaManager;

        public TesoreriaController()
        {
            tesoreriaManager = new TesoreriaManager();
        }

        [HttpGet]
        public JsonResult Tesoreria(string usu, int est)
        {
            switch (Request.HttpMethod)
            {

                case "GET":
                    return Json(tesoreriaManager.ObtenerCartera(usu,est), JsonRequestBehavior.AllowGet);
            }
            return Json(new { Error = true, Message = "Operación HTTP desconocida" });
        }


        //POST: [{"tdt_numero_factura":'1234567891234567891234',"tdt_numero_documeto":'1234567891234567891234',"usu_id":'cvacae@primax.com.ec', "loc_id":206375, "latitud":0.264984,"longitud":-0.15484,"tem_fecha_pago":'5-5-2014',"tet_valor":25.50,"tdt_tipo":1}]
        public JsonResult InsertarTesoreria(int? id, string usu, Tesoreria[] item)
        {
            switch (Request.HttpMethod)
            {
                case "POST":
                    return Json(tesoreriaManager.InsertarTesoreria(item));
                    break;
            }

            return Json(new { Error = true, Message = "Operación HTTP desconocida" });
        }


    }
}
